/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
}

:root {
    --grid-size: 20px;
}

.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* 左侧工具栏样式 */
.sidebar {
    width: 280px;
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
}

.sidebar-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #212529;
}

.node-list {
    height: calc(100% - 50px);
    overflow-y: auto;
    padding: 10px 0;
}

.node-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    margin: 5px 10px;
    background-color: #fff;
    border-radius: 5px;
    cursor: move;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.node-item:hover {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.node-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    margin-right: 12px;
    color: white;
}

.node-item .node-text {
    display: flex;
    flex-direction: column;
}

.node-item .node-title {
    font-weight: 500;
    font-size: 14px;
}

.node-item .node-desc {
    font-size: 12px;
    color: #6c757d;
}

.node-item[data-node-type="start"] .node-icon {
    background-color: #2196f3;
}

.node-item[data-node-type="model"] .node-icon {
    background-color: #4caf50;
}

.node-item[data-node-type="end"] .node-icon {
    background-color: #f44336;
}

.node-item[data-node-type="agent"] .node-icon {
    background-color: #3f51b5;
}

.node-item[data-node-type="ifelse"] .node-icon {
    background-color: #ff9800;
}

.node-item[data-node-type="iterator"] .node-icon {
    background-color: #9c27b0;
}

.node-item[data-node-type="code"] .node-icon {
    background-color: #009688;
}

.node-item[data-node-type="template"] .node-icon {
    background-color: #8bc34a;
}

.node-item[data-node-type="http"] .node-icon {
    background-color: #03a9f4;
}

.node-item[data-node-type="database"] .node-icon {
    background-color: #673ab7;
}

/* 画布容器样式 */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    will-change: transform;
}

/* 画布区域样式 */
.canvas {
    width: 100%;
    height: 100%;
    background-color: #fff;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: auto;
    transform-origin: 0 0;
    transition: transform 0.1s ease-out;
    cursor: default;
    user-select: none;

    /* 始终隐藏滚动条但保留滚动功能 */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

.canvas::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

.canvas:hover:not(.selecting) {
    cursor: grab;
}

.canvas.selecting {
    cursor: crosshair;
}

/* 网格容器样式 */
.grid-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 5000px;
    height: 5000px;
    pointer-events: none;
    background-image: radial-gradient(circle at 1px 1px, #e0e0e0 1px, transparent 1px);
    background-size: 20px 20px;
    z-index: -1;
}

/* 缩略图样式 */
.minimap {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s, transform 0.2s;
}

.minimap:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.minimap-viewport {
    position: absolute;
    border: 2px solid #2196F3;
    background-color: rgba(33, 150, 243, 0.15);
    cursor: grab;
    z-index: 100;
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s;
}

.minimap-viewport:hover {
    background-color: rgba(33, 150, 243, 0.25);
}

.minimap-viewport:active {
    cursor: grabbing;
    background-color: rgba(33, 150, 243, 0.35);
}

.minimap-node {
    position: absolute;
    min-width: 5px;
    min-height: 5px;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    opacity: 0.9;
    z-index: 50;
}

.minimap-node.selected {
    border: 2px solid white !important;
    box-shadow: 0 0 0 1px #2196F3, 0 0 5px rgba(33, 150, 243, 0.5);
    opacity: 1;
    z-index: 51;
}

/* 定义各种节点类型的颜色 */
.minimap-node.start-node {
    background-color: #4CAF50;
}

.minimap-node.end-node {
    background-color: #F44336;
}

.minimap-node.model-node {
    background-color: #2196F3;
}

.minimap-node.agent-node {
    background-color: #9C27B0;
}

.minimap-node.ifelse-node {
    background-color: #FF9800;
}

.minimap-node.iterator-node {
    background-color: #795548;
}

.minimap-node.code-node {
    background-color: #607D8B;
}

.minimap-node.template-node {
    background-color: #00BCD4;
}

.minimap-node.http-node {
    background-color: #FFEB3B;
}

.minimap-node.database-node {
    background-color: #009688;
}

/* 流程节点样式 */
.flow-node {
    position: absolute;
    min-width: 180px;
    background: white;
    border-radius: 6px;
    padding: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    z-index: 10;
    cursor: move;
    user-select: none;
    touch-action: none;
    transition: box-shadow 0.2s, transform 0.1s;
}

.flow-node:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.flow-node.selected {
    border: 2px solid #2196F3;
    box-shadow: 0 0 0 1px #2196F3, 0 4px 12px rgba(33, 150, 243, 0.2);
}

.flow-node.dragging {
    opacity: 0.8;
    cursor: grabbing;
    z-index: 1000;
}

.node-header {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.start-node .node-header {
    background-color: #e3f2fd;
    color: #0d47a1;
    border-bottom: 1px solid #bbdefb;
}

.model-node .node-header {
    background-color: #e8f5e9;
    color: #1b5e20;
    border-bottom: 1px solid #c8e6c9;
}

.end-node .node-header {
    background-color: #fbe9e7;
    color: #bf360c;
    border-bottom: 1px solid #ffccbc;
}

/* 添加新节点类型的样式 */
.agent-node .node-header {
    background-color: #e8eaf6;
    color: #283593;
    border-bottom: 1px solid #c5cae9;
}

.ifelse-node .node-header {
    background-color: #fff3e0;
    color: #e65100;
    border-bottom: 1px solid #ffe0b2;
}

.iterator-node .node-header {
    background-color: #f3e5f5;
    color: #6a1b9a;
    border-bottom: 1px solid #e1bee7;
}

.code-node .node-header {
    background-color: #e0f2f1;
    color: #00695c;
    border-bottom: 1px solid #b2dfdb;
}

.template-node .node-header {
    background-color: #f1f8e9;
    color: #33691e;
    border-bottom: 1px solid #dcedc8;
}

.http-node .node-header {
    background-color: #e1f5fe;
    color: #01579b;
    border-bottom: 1px solid #b3e5fc;
}

.database-node .node-header {
    background-color: #ede7f6;
    color: #4527a0;
    border-bottom: 1px solid #d1c4e9;
}

.node-header i {
    font-size: 16px;
    margin-right: 10px;
}

.flow-node .node-title {
    font-weight: 500;
    font-size: 14px;
    color: #212529;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flow-node .node-content {
    padding: 12px 15px;
    font-size: 13px;
    color: #495057;
}

.flow-node .model-info {
    margin-bottom: 10px;
}

.flow-node .model-type {
    margin-bottom: 8px;
    font-size: 12px;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 6px;
}

.flow-node .model-prompt {
    font-size: 13px;
    color: #495057;
    background-color: #f8f9fa;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    margin-bottom: 8px;
    max-height: 60px;
    overflow: hidden;
}

.flow-node .params-preview {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
}

.flow-node .input-preview,
.flow-node .output-preview {
    display: flex;
    align-items: center;
    gap: 6px;
}

.flow-node .input-preview i {
    color: #28a745;
}

.flow-node .output-preview i {
    color: #007bff;
}

/* 右侧配置面板样式 */
.config-panel {
    width: 340px;
    background-color: #ffffff;
    border-left: 1px solid #dee2e6;
    display: none;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.config-panel.active {
    display: flex;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
}

.panel-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #212529;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #6c757d;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-btn:hover {
    background-color: #e9ecef;
    color: #212529;
}

.panel-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: #495057;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.config-section {
    margin-bottom: 24px;
    padding: 16px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.config-section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.params-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.param-item {
    display: flex;
    gap: 8px;
    align-items: center;
    background-color: white;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.param-name {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
}

.param-type {
    width: 100px;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
    background-color: white;
}

.param-actions {
    display: flex;
    gap: 4px;
}

.add-param,
.remove-param {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    border: none;
}

.add-param {
    background-color: #28a745;
    color: white;
}

.add-param:hover {
    background-color: #218838;
}

.remove-param {
    background-color: #dc3545;
    color: white;
}

.remove-param:hover {
    background-color: #c82333;
}

.save-btn {
    width: 100%;
    padding: 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    margin-top: 20px;
    transition: background-color 0.2s;
    font-size: 15px;
}

.save-btn:hover {
    background-color: #0069d9;
}

/* jsPlumb连接线样式 */
.jtk-connector {
    z-index: 1;
}

/* 连线模式下的样式 */
body.connecting {
    cursor: crosshair;
}

/* 默认情况下隐藏所有连接点 */
.jtk-endpoint,
.node-endpoint,
[class*="jtk-endpoint"] {
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 100;
    pointer-events: auto;
}

/* 合并的规则：节点悬浮或选中时显示所有类型的右侧连接点 */
body:not(.connecting) .flow-node:hover .right-endpoint,
body:not(.connecting) .flow-node:hover .jtk-endpoint[data-anchor="Right"],
body:not(.connecting) .flow-node:hover .jtk-endpoint[anchor="Right"],
body:not(.connecting) .flow-node:hover .jtk-endpoint-anchor-right,
body:not(.connecting) .flow-node:hover .jtk-endpoint[data-anchor*="Right"],
body:not(.connecting) .flow-node:hover .jtk-endpoint[anchor*="Right"],
body:not(.connecting) .flow-node:hover .jtk-endpoint[data-anchor="TopRight"],
body:not(.connecting) .flow-node:hover .jtk-endpoint[data-anchor="BottomRight"],
body:not(.connecting) .flow-node:hover .jtk-endpoint[data-anchor="RightMiddle"],
body:not(.connecting) .flow-node:hover .jtk-endpoint[data-anchor="branch"],
body:not(.connecting) .flow-node:hover .branch-endpoint,
body:not(.connecting) .flow-node.selected .right-endpoint,
body:not(.connecting) .flow-node.selected .jtk-endpoint[data-anchor="Right"],
body:not(.connecting) .flow-node.selected .jtk-endpoint[anchor="Right"],
body:not(.connecting) .flow-node.selected .jtk-endpoint-anchor-right,
body:not(.connecting) .flow-node.selected .jtk-endpoint[data-anchor*="Right"],
body:not(.connecting) .flow-node.selected .jtk-endpoint[anchor*="Right"],
body:not(.connecting) .flow-node.selected .jtk-endpoint[data-anchor="TopRight"],
body:not(.connecting) .flow-node.selected .jtk-endpoint[data-anchor="BottomRight"],
body:not(.connecting) .flow-node.selected .jtk-endpoint[data-anchor="RightMiddle"],
body:not(.connecting) .flow-node.selected .jtk-endpoint[data-anchor="branch"],
body:not(.connecting) .flow-node.selected .branch-endpoint {
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 200;
    transform: scale(1.1);
    pointer-events: auto;
}

/* 确保左侧连接点在普通状态下始终保持隐藏 */
body:not(.connecting) .flow-node:hover .left-endpoint,
body:not(.connecting) .flow-node:hover .jtk-endpoint[data-anchor="Left"],
body:not(.connecting) .flow-node:hover .jtk-endpoint[anchor="Left"],
body:not(.connecting) .flow-node:hover .jtk-endpoint-anchor-left,
body:not(.connecting) .flow-node.selected .left-endpoint,
body:not(.connecting) .flow-node.selected .jtk-endpoint[data-anchor="Left"],
body:not(.connecting) .flow-node.selected .jtk-endpoint[anchor="Left"],
body:not(.connecting) .flow-node.selected .jtk-endpoint-anchor-left {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* 连线模式下只显示通过JavaScript显式设置为可见的左侧连接点 - 高优先级规则 */
body.connecting .jtk-endpoint[data-anchor="Left"].endpoint-visible,
body.connecting .jtk-endpoint[anchor="Left"].endpoint-visible,
body.connecting .left-endpoint.endpoint-visible,
body.connecting .jtk-endpoint-anchor-left.endpoint-visible {
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 200;
    transform: scale(1.1);
    pointer-events: auto;
}

/* 确保在连线模式下，节点悬停或选中不会影响左侧连接点的可见性 - 这是关键规则 */
body.connecting .flow-node:hover .jtk-endpoint[data-anchor="Left"],
body.connecting .flow-node:hover .jtk-endpoint[anchor="Left"],
body.connecting .flow-node:hover .left-endpoint,
body.connecting .flow-node:hover .jtk-endpoint-anchor-left,
body.connecting .flow-node.selected .jtk-endpoint[data-anchor="Left"],
body.connecting .flow-node.selected .jtk-endpoint[anchor="Left"],
body.connecting .flow-node.selected .left-endpoint,
body.connecting .flow-node.selected .jtk-endpoint-anchor-left {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* 确保连线模式下只有通过JavaScript显式设置为可见的左侧连接点才会显示 - 最高优先级 */
body.connecting .flow-node:hover .jtk-endpoint[data-anchor="Left"].endpoint-visible,
body.connecting .flow-node:hover .jtk-endpoint[anchor="Left"].endpoint-visible,
body.connecting .flow-node:hover .left-endpoint.endpoint-visible,
body.connecting .flow-node:hover .jtk-endpoint-anchor-left.endpoint-visible,
body.connecting .flow-node.selected .jtk-endpoint[data-anchor="Left"].endpoint-visible,
body.connecting .flow-node.selected .jtk-endpoint[anchor="Left"].endpoint-visible,
body.connecting .flow-node.selected .left-endpoint.endpoint-visible,
body.connecting .flow-node.selected .jtk-endpoint-anchor-left.endpoint-visible {
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 200;
    transform: scale(1.1);
    pointer-events: auto;
}

/* 确保连线源节点的所有左侧端点始终保持隐藏，无论什么情况 - 最高优先级 */
body.connecting .source-node .jtk-endpoint[data-anchor="Left"],
body.connecting .source-node .jtk-endpoint[anchor="Left"],
body.connecting .source-node .left-endpoint,
body.connecting .source-node .jtk-endpoint-anchor-left,
body.connecting .source-node:hover .jtk-endpoint[data-anchor="Left"],
body.connecting .source-node:hover .jtk-endpoint[anchor="Left"],
body.connecting .source-node:hover .left-endpoint,
body.connecting .source-node:hover .jtk-endpoint-anchor-left,
body.connecting .source-node.selected .jtk-endpoint[data-anchor="Left"],
body.connecting .source-node.selected .jtk-endpoint[anchor="Left"],
body.connecting .source-node.selected .left-endpoint,
body.connecting .source-node.selected .jtk-endpoint-anchor-left,
body.connecting .source-node .jtk-endpoint[data-anchor="Left"].endpoint-visible,
body.connecting .source-node .jtk-endpoint[anchor="Left"].endpoint-visible,
body.connecting .source-node .left-endpoint.endpoint-visible,
body.connecting .source-node .jtk-endpoint-anchor-left.endpoint-visible {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    display: none !important;
}

/* 连线模式下强制隐藏所有右侧连接点，无论节点是否悬浮或选中 */
body.connecting .jtk-endpoint[data-anchor="Right"],
body.connecting .jtk-endpoint[anchor="Right"],
body.connecting .right-endpoint,
body.connecting .jtk-endpoint-anchor-right,
body.connecting .jtk-endpoint[data-anchor*="Right"],
body.connecting .jtk-endpoint[anchor*="Right"],
body.connecting .jtk-endpoint[data-anchor="TopRight"],
body.connecting .jtk-endpoint[data-anchor="BottomRight"],
body.connecting .jtk-endpoint[data-anchor="RightMiddle"],
body.connecting .jtk-endpoint[data-anchor="branch"],
body.connecting .branch-endpoint {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* 修改：在连线模式下显示悬浮节点的右侧连接点 */
body.connecting .flow-node:hover .right-endpoint,
body.connecting .flow-node:hover .jtk-endpoint[data-anchor="Right"],
body.connecting .flow-node:hover .jtk-endpoint[anchor="Right"],
body.connecting .flow-node:hover .jtk-endpoint-anchor-right,
body.connecting .flow-node:hover .jtk-endpoint[data-anchor*="Right"],
body.connecting .flow-node:hover .jtk-endpoint[anchor*="Right"],
body.connecting .flow-node:hover .jtk-endpoint[data-anchor="TopRight"],
body.connecting .flow-node:hover .jtk-endpoint[data-anchor="BottomRight"],
body.connecting .flow-node:hover .jtk-endpoint[data-anchor="RightMiddle"],
body.connecting .flow-node:hover .jtk-endpoint[data-anchor="branch"],
body.connecting .flow-node:hover .branch-endpoint,
body.connecting .flow-node.selected .right-endpoint,
body.connecting .flow-node.selected .jtk-endpoint[data-anchor="Right"],
body.connecting .flow-node.selected .jtk-endpoint[anchor="Right"],
body.connecting .flow-node.selected .jtk-endpoint-anchor-right,
body.connecting .flow-node.selected .jtk-endpoint[data-anchor*="Right"],
body.connecting .flow-node.selected .jtk-endpoint[anchor*="Right"],
body.connecting .flow-node.selected .jtk-endpoint[data-anchor="TopRight"],
body.connecting .flow-node.selected .jtk-endpoint[data-anchor="BottomRight"],
body.connecting .flow-node.selected .jtk-endpoint[data-anchor="RightMiddle"],
body.connecting .flow-node.selected .jtk-endpoint[data-anchor="branch"],
body.connecting .flow-node.selected .branch-endpoint {
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 200;
    pointer-events: auto;
}

/* 当连接点本身被悬浮时，确保同一节点的所有右侧连接点保持可见 */
body:not(.connecting) .flow-node:has(.right-endpoint:hover) .right-endpoint,
body:not(.connecting) .flow-node:has(.jtk-endpoint[data-anchor*="Right"]:hover) .jtk-endpoint[data-anchor*="Right"],
body:not(.connecting) .flow-node:has(.jtk-endpoint[anchor*="Right"]:hover) .jtk-endpoint[anchor*="Right"],
body:not(.connecting) .flow-node:has(.jtk-endpoint-anchor-right:hover) .jtk-endpoint-anchor-right,
body:not(.connecting) .flow-node:has(.jtk-endpoint[data-anchor="TopRight"]:hover) .jtk-endpoint[data-anchor*="Right"],
body:not(.connecting) .flow-node:has(.jtk-endpoint[data-anchor="BottomRight"]:hover) .jtk-endpoint[data-anchor*="Right"],
body:not(.connecting) .flow-node:has(.jtk-endpoint[data-anchor="RightMiddle"]:hover) .jtk-endpoint[data-anchor*="Right"],
body:not(.connecting) .flow-node:has(.branch-endpoint:hover) .branch-endpoint {
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 200;
    transform: scale(1.1);
    pointer-events: auto;
}

/* 当连接点本身被悬浮时的样式增强 */
body:not(.connecting) .right-endpoint:hover,
body:not(.connecting) .jtk-endpoint[data-anchor="Right"]:hover,
body:not(.connecting) .jtk-endpoint[anchor="Right"]:hover,
body:not(.connecting) .jtk-endpoint-anchor-right:hover,
body:not(.connecting) .jtk-endpoint[data-anchor*="Right"]:hover,
body:not(.connecting) .jtk-endpoint[anchor*="Right"]:hover,
body:not(.connecting) .jtk-endpoint[data-anchor="TopRight"]:hover,
body:not(.connecting) .jtk-endpoint[data-anchor="BottomRight"]:hover,
body:not(.connecting) .jtk-endpoint[data-anchor="RightMiddle"]:hover,
body:not(.connecting) .jtk-endpoint[data-anchor="branch"]:hover,
body:not(.connecting) .branch-endpoint:hover {
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 250 !important;
    transform: scale(1.2);
    cursor: pointer;
}

.endpoint-hover {
    transform: scale(1.2);
    transition: transform 0.2s;
}

/* 确保连接点标签在连线模式下也可见 */
.jtk-overlay,
body.connecting .jtk-overlay {
    background-color: white;
    color: #333;
    padding: 2px 4px;
    border: 1px solid #ced4da;
    border-radius: 2px;
    font-size: 12px;
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 201 !important;
}

/* 选择框样式 */
.selection-box {
    position: absolute;
    border: 1px dashed #007bff;
    background-color: rgba(0, 123, 255, 0.1);
    pointer-events: none;
    z-index: 999;
    display: none;
}

/* 画布交互模式样式 */
.canvas.pointer {
    cursor: default;
}

.canvas.pointer:hover {
    cursor: default;
}

.canvas.hand {
    cursor: grab;
}

.canvas.hand:active {
    cursor: grabbing;
}

.canvas.selecting {
    cursor: crosshair;
}

.canvas.pointer.selecting {
    cursor: crosshair;
}

/* 画布控制按钮 */
.canvas-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.control-group {
    display: flex;
    gap: 8px;
}

.control-btn {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    background-color: white;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background-color: #f8f9fa;
    color: #007bff;
    border-color: #007bff;
}

.control-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.control-btn i {
    font-size: 16px;
}

/* 缩放样式 */
.canvas.zoomed {
    transform-origin: center center;
}

/* 锁定状态 */
.canvas.locked {
    cursor: not-allowed;
}

/* 左下角拖拽图标样式 */
.drag-icon {
    position: absolute;
    left: 20px;
    bottom: 20px;
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
}

.drag-icon:hover {
    background-color: rgba(240, 240, 240, 1);
    transform: scale(1.1);
}

.drag-icon i {
    font-size: 18px;
    color: #555;
}

/* 节点分类 */
.node-category {
    margin-bottom: 15px;
}

.category-title {
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    padding: 0 10px 5px;
    margin-bottom: 5px;
    border-bottom: 1px solid #e9ecef;
}

/* 新增的配置面板样式 */
.tools-container {
    margin-bottom: 15px;
}

.tool-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.tool-name,
.tool-description {
    flex: 1;
    margin-right: 10px;
}

.delete-tool-btn {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 14px;
}

.code-editor {
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.5;
    tab-size: 4;
}

/* 参数项样式改进 */
.param-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 10px;
    border: 1px solid #e9ecef;
}

.param-name {
    flex: 2;
    margin-right: 10px;
}

.param-type {
    flex: 1;
    margin-right: 10px;
}

.form-check {
    margin-right: 10px;
    display: flex;
    align-items: center;
}

.delete-param-btn {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 14px;
}

/* 配置部分的样式更新 */
.config-section {
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 15px;
    background-color: #fff;
}

.config-section-title {
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e9ecef;
    color: #495057;
    display: flex;
    align-items: center;
}

.config-section-title i {
    margin-right: 8px;
    color: #6c757d;
}

/* 表单控件样式增强 */
.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    color: #495057;
    background-color: #fff;
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* 连接线加号按钮和菜单样式 */
.connection-add-button {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: white;
    border: 2px solid #6c757d;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    transform: translate(-50%, -50%);
}

/* 确保按钮在悬浮时保持显示 */
.connection-add-button:hover {
    transform: translate(-50%, -50%) scale(1.2);
    background-color: #f8f9fa;
    border-color: #007bff;
    color: #007bff;
    opacity: 1 !important;
    visibility: visible !important;
}

.connection-menu {
    position: fixed;
    /* 改用fixed定位 */
    background-color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 8px 0;
    z-index: 1000;
    min-width: 180px;
    transform: translate(-50%, -50%);
    /* 确保居中显示 */
}

.menu-item {
    padding: 8px 16px;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.menu-item:hover {
    background-color: #f0f4f8;
}

/* 确保连接线在悬浮时显示加号按钮 */
.jtk-connector:hover+.connection-add-button,
.jtk-connector.hover+.connection-add-button {
    opacity: 1;
}

.jtk-endpoint-anchor-right {
    background-color: #4caf50;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

.jtk-endpoint-anchor-left {
    background-color: #2196f3;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}